/*============================================================================
 PROJECT: Halalgems
 FILE:    Ultils.h
 AUTHOR:  Nguyen Quang Khai
 =============================================================================*/

/*============================================================================
 IMPORT
 =============================================================================*/

#import <Foundation/Foundation.h>
#import "MBProgressHUD.h"
/*============================================================================
 MACRO
 =============================================================================*/

/*============================================================================
 PRIVATE INTERFACE
 =============================================================================*/

/*----------------------------------------------------------------------------
 Interface:   Ultils
 -----------------------------------------------------------------------------*/
@class User;

@interface NLUtils : NSObject{
}
/* return image from color*/
- (UIImage *)imageWithColor:(UIColor *)color;

/* get size NSString */
+(CGSize)sizeOfString:(NSString*)string andFont:(UIFont*)font andMaxSize:(CGSize)maxSize;
/*----------------------------------------------------------------------------
 Method:      convertDayToInteger
 Description: convert day to integer
 -----------------------------------------------------------------------------*/
+(NSInteger)convertDayToInteger:(NSDate*)date;
/*----------------------------------------------------------------------------
 Method:      convertDataDeviceTokenToString   
 Description: convert nssdata device token to nsstring
 -----------------------------------------------------------------------------*/
+(NSString*)convertDataDeviceTokenToString:(NSData*)deviceToken;/*----------------------------------------------------------------------------
 Method:      radiusView:   
 Description: Radis view
 -----------------------------------------------------------------------------*/
+(void)radiusView:(UIView*)view;
/*----------------------------------------------------------------------------
 Method:      convertIntToDateString   
 Description: Convert int to date'string
 -----------------------------------------------------------------------------*/
+(NSString*)convertIntToDateString:(long)value;
/*----------------------------------------------------------------------------
 Method:      convertDateToIntValue   
 Description: Convert date'string to int
 -----------------------------------------------------------------------------*/
+(NSInteger)convertDateToIntValue:(NSString*)dateString;
/*----------------------------------------------------------------------------
 Method:      convertIntToDateStringTimeActiveCupid   
 Description: Convert to format string hh-mm MM-dd-yyyy
 -----------------------------------------------------------------------------*/
+(NSString *)convertIntToDateStringTimeActiveCupid:(long)value;
/*----------------------------------------------------------------------------
 Method:      showAndHideProgressHUDWithFlag
 Description: Show HUD view to wait for main thread processing
 -----------------------------------------------------------------------------*/
+(void)showAndHideProgressHUDWithFlag:(BOOL)flag andView:(UIView*)view;

/*----------------------------------------------------------------------------
 Method:      convertIntToDateStringTimeSendSystem
 Description: Convert to format string hh:mm
 -----------------------------------------------------------------------------*/
+(NSString *)convertIntToDateStringTimeSendSystem:(long)value;

/*----------------------------------------------------------------------------
 Method:      compareTwoDayWithLongValue
 Description: compare 2 day ( now and long value )
 -----------------------------------------------------------------------------*/
+(NSString*)compareTwoDayWithLongValue:(long long)value;

+ (void)showAlertWithMessage:(NSString *)mess;

+ (void)showConfirmAlertWithMessage:(NSString *)mess delegate:(id)delegate;

+ (NSString *)base64forData:(NSData *)theData;

/* for Images */
+ (UIImage *)stretchImagedName:(NSString *)imageName leftPadding:(CGFloat)leftPadding topPadding:(CGFloat)padding;

+ (UIImage *)stretchImagedName:(NSString *)imageName topPadding:(CGFloat)padding;

+ (UIImage *)middleStretchImagedName:(NSString *)imageName;

+ (UIImage *)tiledImageName:(NSString *)imageName edgeInset:(UIEdgeInsets)inset;

+ (UIColor *)colorFromHexaCode:(NSString *)haxaStr;

+ (UIImage *)imageFromColor:(UIColor *)color rect:(CGRect)rect;

+ (UIImage *)imageFromColor:(UIColor *)color;

/* Handle deprecations */
+ (CGSize)constrainedBoundsForText:(NSString *)text
                              font:(UIFont *)font
                     lineBreakMode:(NSInteger)lineBreakMode
                     textAlignment:(NSInteger)textAlignment
                         limitSize:(CGSize)limitSize;


+ (CGSize)constrainSizeForLabel:(UILabel *)label autoFitSize:(AutoFitSize)mode;

+ (CGSize)constrainSizeForControl:(UIView *)label autoFitSize:(AutoFitSize)mode;

/* Show loading indicator */
+ (void)showNetworkActivityIndicator;

+ (void)hideNetworkActivityIndicator;

/* for emergency */
+ (BOOL)isText:(NSString *)text includedInArray:(NSMutableArray *)arr;

+ (NSArray *)wordsInText:(NSString *)text;

/* for chatting */
+ (NSString *)formatSentDate:(NSDate *)sentDate;

/* for time */
+ (NSString *)shortTime:(NSString *)timeString;

/* Conver hexa string to int */
+ (int)intValueWithHexaString:(NSString *)hexaString;

/* for encrypt */
+ (NSString *)sha512:(NSString *)input;

/* for oauth */
+ (NSString *)appendParams:(NSMutableDictionary *)params;

+ (NSString *)AFNounce;

+ (NSString *)AFHMACSHA1Signature:(NSURLRequest *)request
                   consumerSecret:(NSString *)consumerSecret
                      tokenSecret:(NSString *)tokenSecret
                   stringEncoding:(NSStringEncoding)stringEncoding;


/* get crc32 of file */
+ (uint32_t)CRC32ValueWithData:(NSData *)data;

+ (UInt32)getCrc32:(NSData *)data;

+ (NSString *)sizeToString:(double)convertedValue;

+ (NSString *)distanceToString:(double)convertedValue hasDecimal:(BOOL)hasDecimal;

+ (NSString *)timeToString:(double)convertedValue hasDecimal:(BOOL)hasDecimal;

+ (NSString *)timeStringFromSeconds:(double)seconds;

+ (CGSize)sizeForText:(NSString *)text label:(UILabel *)label;

+ (NSString *)convertArray:(NSArray *)objs
toStringWithSeperateString:(NSString *)string
                usingBlock:(NSString *(^)(id obj))block;

+ (NSString *)convertArray:(NSArray *)objs toStringWithSeperateCommaUsingBlock:(NSString *(^)(id obj))block;

+ (NSString *)valueToString:(double)convertedValue;

+ (NSString *)numberStringFromString:(NSString *)originalString;


#pragma mark - Enums for XMPP
#define kXMPPStatusStringKey    @"kXMPPStatusStringKey"
#define kXMPPStatusImageKey     @"kXMPPStatusImageKey"

+ (NSDictionary *)valuesForXMPPID:(NSString *)jID;

/* for Data */
+ (NSData *)compressImage:(UIImage *)image toSize:(CGSize)size limitDataSize:(NSInteger)limitDataSize;
+ (NSData *)compressImage:(UIImage *)image toSize:(CGSize)size;

/******************************************************************************
 Locations
 ******************************************************************************/
+ (BOOL)isValidLatitude:(double)latitude longitude:(double)longitude;

/******************************************************************************
 Operations
 ******************************************************************************/
+ (void)asynExecuteBlock:(void(^)())block;
+ (void)synExecuteBlock:(void(^)())block;
+ (void)executeAfterSeconds:(double)seconds block:(void(^)())block;

@end
